#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

int main()
{
    int n = 0, m = 0;
    cin >> n >> m;
    int count = n;
    for (int i = 1;i < m;i++)
    {
        count *= (n - 1);
        count %= 109;
    }
    cout << count << endl;
    return 0;
}
